package com.qzsoft.zhjd.materiel.modules.materieldata.dto;

import java.math.BigDecimal;
import java.util.Date;

import com.fasterxml.jackson.annotation.JsonFormat;

import com.qzsoft.jeemis.common.annotation.Dict;
import com.qzsoft.zhjd.materiel.modules.materieldata.enmus.WeightTypeEnum;

import lombok.Data;

/**
 * @ClassName MaterielDataListDto
 * @Description 数据列表对象
 * @author linhuawei
 * @since 2021-09-01
 */
@Data
public class MaterielDataListDto {

    /**
     * 主键
     */
    private String id;

    /**
     * 设备编号
     */
    private String deviceCode;

    /**
     * 设备名称
     */
    private String deviceName;

    /**
     * 物料唯一标识
     */
    private String materielItemId;

    /**
     * 物料名称
     */
    private String materielItemName;

    /**
     * 物料规格
     */
    private String materielItemSpec;

    /**
     * 材料单位
     */
    private String materielItemUnit;

    /**
     * 材料单位
     */
    @Dict(dictCodeId = "MATERIEL_UNIT", dicCodeField = "materielItemUnit")
    private String materielItemUnitLabel;

    /**
     * 操作员主键
     */
    private String operatorId;

    /**
     * 操作员姓名
     */
    private String operatorName;

    /**
     * 供应商主键
     */
    private String supplierId;

    /**
     * 供应商主键
     */
    private String supplierName;

    /**
     * 用料项目/单位主键
     */
    private String projectId;

    /**
     * 用料项目/单位主键
     */
    private String projectName;

    /**
     * 收发料单位名称
     */
    private String supplierOrProjectName;

    /**
     * 磅单编号
     */
    private String weightCode;

    /**
     * 过磅类型：0=收料，1=发料
     */
    private String weightType;

    /**
     * 数据类型
     */
    @Dict(dictCodeId = "WEIGHT_TYPE", dicCodeField = "weightType")
    private String weightTypeLabel;

    /**
     * 数据类型（采购、销售等）
     */
    private String weightDataType;

    /**
     * 数据类型
     */
    @Dict(dictCodeId = "WEIGHT_TYPE", dicCodeField = "weightDataType")
    private String weightDataTypeLabel;

    /**
     * 数据来源：0称重，1补录
     */
    private String weightDataSource;

    /**
     * 数据来源：0称重，1补录
     */
    @Dict(dictCodeId = "WEIGHT_DATA_SOURCE", dicCodeField = "weightDataSource")
    private String weightDataSourceLabel;

    /**
     * 偏差：0=正常，1=超负差，2=超正差
     */
    private String deviationType;

    /**
     * 毛重/t
     */
    private BigDecimal grossWeight;

    /**
     * 皮重/t
     */
    private BigDecimal tareWeight;

    /**
     * 扣重占比
     */
    private BigDecimal deductionRatio;

    /**
     * 扣重/t
     */
    private BigDecimal deductionWeight;

    /**
     * 净重/t
     */
    private BigDecimal netWeight;

    /**
     * 实际重量
     */
    private BigDecimal weight;

    /**
     * 实际数量
     */
    private BigDecimal quantity;

    /**
     * 运单编号
     */
    private BigDecimal waybillCode;

    /**
     * 运单重量/t
     */
    private BigDecimal waybillWeight;

    /**
     * 运单数量
     */
    private BigDecimal waybillQuantity;

    /**
     * 进磅时间
     */
    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss")
    private Date entryTime;

    /**
     * 出磅时间
     */
    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss")
    private Date exitTime;

    /**
     * 车牌号
     */
    private String carNumber;

    /**
     * 是否废弃：0=否，1=是
     */
    private Integer disable;

    /**
     * 磅单状态
     */
    private String disableLabel;

    private String updateName;
    /**
     * 修改时间
     */
    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss")
    private Date updateDate;

    public String getSupplierOrProjectName() {
        if (null != weightType) {
            if (WeightTypeEnum.SEND.getValue().equals(weightType)) {
                supplierOrProjectName = projectName;
            } else if (WeightTypeEnum.RECEIVE.getValue().equals(weightType)) {
                supplierOrProjectName = supplierName;
            }
        }
        return supplierOrProjectName;
    }

    public String getDisableLabel() {
        if (null != disable) {
            if (0 == disable) {
                disableLabel = "正常";
            } else if (1 == disable) {
                disableLabel = "废弃";
            }
        }
        return disableLabel;
    }

}
